package com.liliya.servlet.order;

import com.liliya.pojo.Order;
import com.liliya.service.OrderService;
import com.liliya.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2021/2/21 9:22
 */
@WebServlet(urlPatterns = "/order/todetail")
public class OrdertodetailServlet extends HttpServlet {
    private OrderService orderService = new OrderServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String orderNum = req.getParameter("orderNum");
        int num = 1;
        if (orderNum!=null) {
            num = Integer.parseInt(orderNum);
        }
        Order order = orderService.findOrderByOrderNum(num);
        req.setAttribute("order",order);
        req.getRequestDispatcher("./ordertodetail.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
